#include "GMClientAccepted.h"
#include "Factory.h"
#include "Timer.h"
#include "SendGameMessage.h"
#include "ClientPlayerManager.h"

#include <iostream>

GMClientAccepted::GMClientAccepted()
{
	m_id = -1;
}

void GMClientAccepted::Execute()
{
	// add to the other clients draw manager
	std::cout << "clientaccepted exectued" << std::endl;
}

bool GMClientAccepted::Read(SocketMessage* sm)
{
	sm->ReadInt(&m_id);

	std::cout << "Client: " << m_id << " was added" << std::endl;
	TheCPManager::Instance()->AddClient(m_id, ClientInfo());

	return true;
}

void GMClientAccepted::Write(SocketMessage* sm)
{
	sm->WriteString("GMClientAccepted");
	sm->WriteInt(m_id);
}

void GMClientAccepted::SetID(int i)
{
	m_id = i;
}

int GMClientAccepted::GetID() const
{
	return m_id;
}